﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MovieRental.Entities;
using MovieRental.BuisnessComponents;
using System.ComponentModel;

namespace MovieRental.EnhancedEntities
{
    public class Customer : BaseEnhancedEntity<CustomerInfo>
    {
        public Customer(CustomerInfo entity)
            : base(entity)
        {
        }

        protected override void EntityChanged(object sender, PropertyChangedEventArgs e)
        {
            OnPropertyChanged("FullName");
        }

        public string FullName
        {
            get { return string.Format("{0} {1}", Entity.FirstName, Entity.LastName); }
        }

        public int NotReturnedEditions
        {
            get { return ComponentFactory.Instance.GetLoanCartComponent().GetNotReturnedEditionsCount(Entity.Id); }
        }

        public int ReturnedEditions
        {
            get { return ComponentFactory.Instance.GetLoanCartComponent().GetReturnedEditionsCountForCustomer(Entity); }
        }

        public double SpentMoney
        {
            get { return ComponentFactory.Instance.GetLoanCartComponent().CountSpentMoney(Entity.Id); }
        }

        public double MustReturnMoney
        {
            get { return ComponentFactory.Instance.GetLoanCartComponent().CountMustReturnMoney(Entity.Id); }
        }

        public double PersonalDiscountValue
        {
            get { return ComponentFactory.Instance.GetPersonalDiscountComponent().GetAvailablePersonalDiscountValue(Entity.Id); }
        }

        
    }
}
